home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-12-20 | 1.9 KB | 72 lines | [TEXT/GEOL] |
- Item forwarded by SCHMUCKER1 to NASSI
-
- Item 3184957 16-Dec-89 18:57
-
- From: D2022 Strata, Gary Bringhurst,PRT
-
- To: CPLUS.APPLE$ C++ Interest List--Apple Employees
- CPLUS.DEV$ C++ Interest List--Developers
-
- cc: MACDTS Macintosh Developer Tech. Supt.
-
- Sub: What gives here?
-
- When the C++ compiler is given the following class definitions:
-
- ----
-
- class A {
- virtual void foo(int& i) = 0;
- virtual void foo(char& c) = 0;
- };
-
- class B : public A {
- void foo(int& i);
- void foo(char& c);
- virtual void foo(float& f) = 0;
- virtual void foo(double& d) = 0;
- };
-
- class C : public B {
- void foo(float& f);
- void foo(double& d);
- };
-
- ----
-
- it reacts with these warnings:
-
- File "test.h"; line 15 # warning: C::foo() hides virtual B::foo() of type
- void B:: (int &)
- File "test.h"; line 15 # warning: C::foo() hides virtual B::foo() of type
- void B:: (char &)
-
- What gives here? My intent is that the pure virtual methods of class A be
- defined within class B, which then adds two new pure virtual methods, which are
- defined in class C. Class C is the only non-abstract class among the three.
- Note that the following modification to class C will get rid of the warnings:
-
- ----
-
- class C : public B {
- void foo(int& i);
- void foo(char& c);
- void foo(float& f);
- void foo(double& d);
- };
-
- ----
-
- If I have the first two methods simply call their counterparts in class B I get
- the behaviour I want, but at the expense of an additional jsr. Why does the
- compiler force me to redefine these methods? Am I missing something here?
- It's very common to build new abstract classes upon other abstract classes,
- while providing incremental functionality. Any answers are appreciated.
-
- Thanks in advance.
-
- Gary L. Bringhurst
- Strata Inc.
- D2022
-
-